#ifndef __GLES2HardwareVertexBuffer_H__
#define __GLES2HardwareVertexBuffer_H__

#include "HardwareVertexBuffer.h"

namespace PVM
{
	class GLES2HardwareVertexBuffer : public HardwareVertexBuffer
	{
	private:
		GLuint mBufferId;
		bool mLockedToScratch;
		size_t mScratchOffset;
		size_t mScratchSize;
		void* mScratchPtr;
		bool mScratchUploadOnUnlock;
		
	protected:
		void* lockImpl(size_t offset, size_t length, LockOptions options);
		void unlockImpl(void);
		
	public:
		GLES2HardwareVertexBuffer(HardwareBufferManagerBase* mgr, size_t vertexSize, size_t numVertices,
								  HardwareBuffer::Usage usage, bool useShadowBuffer);
		virtual ~GLES2HardwareVertexBuffer();
		
		void readData(size_t offset, size_t length, void* pDest);
		void writeData(size_t offset, size_t length,
					   const void* source, bool discardWholeBuffer = false);
		void _updateFromShadow(void);
		inline GLuint getGLBufferId(void) const {return mBufferId;}
	};
}

#endif
